from rest_framework import serializers

from . import models


# 文章 序列化器
class ArticleSerializer(serializers.ModelSerializer):

    tag = serializers.StringRelatedField(read_only=True, many=True)

    class Meta:
        model = models.Article
        fields = '__all__'


# 文章标签 序列化器
class TagSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.Tag
        fields = ['name']
